package com.bdqn.quartz1.config;

import com.bdqn.quartz1.entity.QuartzJob2;
import org.quartz.JobDataMap;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;

@Configuration
public class QuartzConfig {
    @Bean
    MethodInvokingJobDetailFactoryBean jobDetail() {
        MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean();
        jobDetail.setTargetBeanName("quartzJob1");
        jobDetail.setTargetMethod("doJob");
        return jobDetail;
    }

    @Bean
    JobDetailFactoryBean jobDetail2() {
        JobDetailFactoryBean jobDetail = new JobDetailFactoryBean();
        jobDetail.setJobClass(QuartzJob2.class);
        JobDataMap map = new JobDataMap();
        map.put("orderNo", 1001);
        jobDetail.setJobDataMap(map);
        jobDetail.setDurability(true);
        return jobDetail;
    }
}
